<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

Route::namespace('Api')->middleware('cors')->group(function () {
    Route::middleware('api.guard', 'throttle:1000,1')->group(function () {
            //API鉴权
            Route::post('/authorization', 'UserController@authorization');
            Route::get('/weixin', 'WeChatController@index');
//        Route::post('/notify', 'AlipayController@callback');
            Route::middleware('api.refresh')->group(function () {
                Route::get('/productList', 'ProductController@index');
                Route::get('/queryAccount', 'AccountController@queryAccount');
                Route::post('/alipayAuth', 'AlipayController@auth');
                Route::post('/ali_pay', 'AlipayController@pay');
                Route::post('/recharge', 'RechargeController@doRecharge');
                Route::get('/alipayTradeQuery', 'AlipayController@queryPaymentByTradeNo');
                Route::get('/bindAccountList', 'BindAccountController@personList');
            });
            Route::get('/getToken', 'AuthController@getToken');
            Route::get('/wx', 'EntranceController@index');
            Route::post('/wx', 'EntranceController@index');

            Route::group(['middleware' => ['web']], function () {
                Route::get('/recharge', 'EntranceController@recharge');
                Route::get('/buyProduct', 'EntranceController@buyProduct');
                Route::get('/bindInfo', 'EntranceController@bindInfo');
                Route::get('/record', 'EntranceController@record');
                Route::get('/rechargeDetail', 'EntranceController@rechargeDetail');
            });
            Route::get('/getCon','EntranceController@getCon');
//        Route::post('/addressProcess', 'EntranceController@addressProcess');
            Route::post('/doRecharge', 'RechargeController@doRecharge');
            Route::get('/tradeNo', 'EntranceController@getTradeNo');
            Route::get('/redirectUrl', 'EntranceController@redirectUrl');

            Route::get('/payResult', 'EntranceController@payResult');
            Route::post('/buySim', 'RechargeController@buySim');
            Route::post('/createOrder', 'PayController@index');
            Route::post('/notify', 'PayController@notify');
            Route::post('/testMsg','EntranceController@testMsg');

            Route::get('/supportModel','EntranceController@supportModel');
    });

    //Data synchronization api routing
    Route::post('data-sync', 'DataSyncController@request');
});
